import { defHttp } from '/@/utils/http/axios';
import { ContentTypeEnum } from '/@/enums/httpEnum';

enum FormVO {
  //流程表单
  getformpage = '/admin-api/bpm/form/page',
  getform = '/admin-api/bpm/form/get',
  createform = '/admin-api/bpm/form/create',
  updateform = '/admin-api/bpm/form/update',
  deleteform = '/admin-api/bpm/form/delete',
  //流程模型
  getModelList = '/admin-api/bpm/model/page',
  getModelAdd = '/admin-api/bpm/model/create',
  getModelEdit = '/admin-api/bpm/model/update',
  getModelDelete = '/admin-api/bpm/model/delete',
  getModelInfo = '/admin-api/bpm/model/get',
  getModelPut = '/admin-api/bpm/model/create',
  getFromSimple = '/admin-api/bpm/form/list-all-simple',
  getModeTaskInfo = '/admin-api/bpm/task-assign-rule/list',
  getModelTaskEdit = '/admin-api/bpm/task-assign-rule/update',
  getModelTaskCreate = '/admin-api/bpm/task-assign-rule/create',
  getModelDefine = '/admin-api/bpm/process-definition/page',
  getModelState = '/admin-api/bpm/model/update-state',
  getModeArrange = '/admin-api/bpm/model/deploy',
  //额外请求信息
  getroleSimple = '/admin-api/system/role/list-all-simple',
  getDeptSimple = '/admin-api/system/dept/list',
  getPostSimple = '/admin-api/system/post/list-all-simple',
  getUserSimple = '/admin-api/system/user/list-all-simple',
  getUserGroupSimple = '/admin-api/bpm/user-group/list-all-simple',
}

export type ProcessDefinitionVO = {
  id: string;
  version: number;
  deploymentTIme: string;
  suspensionState: number;
};
export type ModelVO = {
  id: number;
  formName: string;
  key: string;
  name: string;
  description: string;
  category: string;
  formType: number;
  formId: number;
  formCustomCreatePath: string;
  formCustomViewPath: string;
  processDefinition: ProcessDefinitionVO;
  status: number;
  remark: string;
  createTime: string;
  bpmnXml: string;
};
// 获取表单分页
export const getFormPage = (params: any) => {
  return defHttp.get<any>(
    { url: FormVO.getformpage, params },
    { withToken: false, withUserId: true },
  );
};
export const getForm = (params: any) => {
  return defHttp.get<any>({ url: FormVO.getform, params }, { withToken: false, withUserId: true });
};
export const createForm = (params: any) => {
  return defHttp.post<any>({ url: FormVO.createform, params });
};
export const updateForm = (params: any) => {
  return defHttp.put<any>({ url: FormVO.updateform, params });
};
export const deleteForm = (params: any) => {
  return defHttp.delete<any>(
    {
      url: FormVO.deleteform,
      params,
      headers: { 'Content-Type': ContentTypeEnum.FORM_URLENCODED },
    },
    { joinParamsToUrl: true },
  );
};
//表单模型
export const modeList = (params: any) => {
  return defHttp.get<any>({ url: FormVO.getModelList, params });
};
export const modeInfo = (params: any) => {
  return defHttp.get<any>(
    { url: FormVO.getModelInfo, params },
    { withToken: false, withUserId: true },
  );
};
export const modelAdd = (params: any) => {
  return defHttp.post<any>({ url: FormVO.getModelAdd, params });
};
export const modelEdit = (params: any) => {
  return defHttp.put<any>({ url: FormVO.getModelEdit, params });
};
export const modelDelete = (params: any) => {
  return defHttp.delete<any>({
    url: FormVO.getModelDelete,
    params,
    headers: { 'Content-Type': ContentTypeEnum.FORM_URLENCODED },
  });
};
export const modelPutEdit = (params: any) => {
  return defHttp.put<any>({ url: FormVO.getModelPut, params });
};
export const modeFromSimple = (params: any) => {
  return defHttp.get<any>(
    { url: FormVO.getFromSimple, params },
    { withToken: false, withUserId: true },
  );
};
export const modeTaskList = (params: any) => {
  return defHttp.get<any>(
    { url: FormVO.getModeTaskInfo, params },
    { withToken: false, withUserId: true },
  );
};
export const modelTaskEdit = (params: any) => {
  return defHttp.put<any>({ url: FormVO.getModelTaskEdit, params });
};
export const modelTaskCreate = (params: any) => {
  return defHttp.post<any>({ url: FormVO.getModelTaskCreate, params });
};
export const modeDefineList = (params: any) => {
  return defHttp.get<any>(
    { url: FormVO.getModelDefine, params },
    { withToken: false, withUserId: true },
  );
};
export const modelState = (params: any) => {
  return defHttp.put<any>({ url: FormVO.getModelState, params });
};
export const modelArrangeAdd = (params: any) => {
  return defHttp.post<any>({
    url: FormVO.getModeArrange,
    params,
    headers: { 'Content-Type': ContentTypeEnum.FORM_URLENCODED },
  });
};

//额外请求信息
export const roleSimple = (params: any) => {
  return defHttp.get<any>({ url: FormVO.getroleSimple, params });
};
export const deptSimple = (params: any) => {
  return defHttp.get<any>({ url: FormVO.getDeptSimple, params });
};
export const postSimple = (params: any) => {
  return defHttp.get<any>({ url: FormVO.getPostSimple, params });
};
export const userSimple = (params: any) => {
  return defHttp.get<any>({ url: FormVO.getUserSimple, params });
};
export const userGroupSimple = (params: any) => {
  return defHttp.get<any>({ url: FormVO.getUserGroupSimple, params });
};
